{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "angry-sudan",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "embedded-competition",
   "metadata": {},
   "outputs": [],
   "source": [
    "re.fullmatch(\".hi\", \"ddhi\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "elder-composite",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/design-add-and-search-words-data-structure\n",
    "\n",
    "\n",
    "Runtime: 1464 ms, faster than 5.06% of Python3 online submissions for Design Add and Search Words Data Structure.\n",
    "Memory Usage: 24.7 MB, less than 86.52% of Python3 online submissions for Design Add and Search Words Data Structure.\n",
    "\n",
    "\n",
    "```python\n",
    "import re\n",
    "\n",
    "class WordDictionary:\n",
    "\n",
    "    def __init__(self):\n",
    "        \"\"\"\n",
    "        Initialize your data structure here.\n",
    "        \"\"\"\n",
    "        #7:29\n",
    "        self.l = []\n",
    "        self.d = dict()\n",
    "        #8:00\n",
    "\n",
    "    def addWord(self, word: str) -> None:\n",
    "        self.l.append(word)\n",
    "        self.l.sort()\n",
    "        self.d.update({len(word): 0})\n",
    "\n",
    "    def search(self, word: str) -> bool:\n",
    "        if len(word) not in self.d.keys():\n",
    "            return False\n",
    "        for w in self.l:\n",
    "            if re.fullmatch(word, w) != None:\n",
    "                return True\n",
    "        return False\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "structural-fundamentals",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
